package com.learn.algorlthm;

/**
 * @classname:
 * @Description:删除链表中重复的结点
 * @author: yfpu(fengpu.yang @ ucarinc.com)
 * @Date: 2018-07-24 10:04
 */
public class Learn18_2 {

    public ListNode deleteDuplication(ListNode pHead) {
        if (pHead == null || pHead.next == null)
            return pHead;
        ListNode next = pHead.next;
        if (pHead.val == next.val) {
            while (next != null && pHead.val == next.val)
                next = next.next;
            return deleteDuplication(next);
        } else {
            pHead.next = deleteDuplication(pHead.next);
            return pHead;
        }
    }




    class ListNode {
        public String val;
        public ListNode next;
    }

}
